local ma__shenfen = fk.CreateSkill {
  name = "ma__shenfen",
}

Fk:loadTranslationTable{
  ["ma__shenfen"] = "神愤",
  [":ma__shenfen"] = "出牌阶段限一次，你可以失去共计6点体力和“暴怒”，对所有其他角色各造成1点伤害，然后这些角色各弃置其装备区里的所有牌，"..
  "各弃置四张手牌，最后你翻面。",

  ["#ma__shenfen"] = "神愤：选择要失去的暴怒数量（少于6的部分改为扣除体力值），对所有角色造成伤害并弃牌！",

  ["$ma__shenfen1"] = "神怒降世，炼狱即临！",
  ["$ma__shenfen2"] = "吾怒如火，焚汝残躯！",
}

ma__shenfen:addEffect("active", {
  anim_type = "big",
  card_num = 0,
  target_num = 0,
  interaction = function(self, player)
    return UI.Spin {
      from = (6 - player.hp),
      to = math.min(6, player:getMark("@baonu")),
    }
  end,
  can_use = function(self, player)
    return player:usedSkillTimes(ma__shenfen.name, Player.HistoryPhase) == 0 and player.hp >= (6 - player:getMark("@baonu")) and
      #Fk:currentRoom().alive_players > 1
  end,
  card_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local n = self.interaction.data
    room:removePlayerMark(player, "@baonu", n)
    room:loseHp(player, (6 - n), ma__shenfen.name)
    if player.dead then return end
    local tos = room:getOtherPlayers(player)
    room:doIndicate(effect.from.id, table.map(tos, Util.IdMapper))
    for _, p in ipairs(tos) do
      if not p.dead then
        room:damage{
          from = player,
          to = p,
          damage = 1,
          skillName = ma__shenfen.name,
        }
      end
    end
    for _, p in ipairs(tos) do
      if not p.dead then
        p:throwAllCards("e")
      end
    end
    for _, p in ipairs(tos) do
      if not p.dead then
        room:askToDiscard(p, {
          min_num = 4,
          max_num = 4,
          include_equip = false,
          skill_name = ma__shenfen.name,
          cancelable = false,
        })
      end
    end
    if not player.dead then
      player:turnOver()
    end
  end
})

return ma__shenfen
